<% layout('/layouts/default.html', {title: '栏目管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
 				<i class="fa icon-organization"></i> ${text('栏目管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i>${text('查询')}</a>
				<a href="#" class="btn btn-default" id="btnRefreshTree" title="${text('刷新')}"><i class="fa fa-refresh"></i> ${text('刷新')}</a>
				<a href="#" class="btn btn-default" id="btnExpandTreeNode" title="${text('展开一级')}"><i class="fa fa-angle-double-down"></i>${text('展开')}</a>
				<a href="#" class="btn btn-default" id="btnCollapseTreeNode" title="${text('折叠全部')}"><i class="fa fa-angle-double-up"></i> ${text('折叠')}</a> <%
				if(hasPermi('cms:category:edit')){ %>
					<a href="${ctx}/cms/category/form" class="btn btn-default btnTool" title="${text('栏目添加')}"><i class="fa fa-plus"></i>${text('新增')}</a>
				<% } %>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${category}" action="${ctx}/cms/category/listData" method="post" class="form-inline hide"
				data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('栏目名称')}：</label>
					<div class="control-inline">
						<#form:input path="categoryName" maxlength="100" class="form-control width-120" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('站点编码')}：</label>
					<div class="control-inline">
						<#form:input path="siteCode" maxlength="64" class="form-control width-120" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('模块类型')}：</label>
					<div class="control-inline">
						<#form:input path="moduleType" maxlength="50" class="form-control width-120" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('栏目图片')}：</label>
					<div class="control-inline">
						<#form:input path="image" maxlength="255" class="form-control width-120" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('链接')}：</label>
					<div class="control-inline">
						<#form:input path="href" maxlength="255" class="form-control width-120" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('目标')}：</label>
					<div class="control-inline">
						<#form:input path="target" maxlength="20" class="form-control width-120" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('关键字')}：</label>
					<div class="control-inline">
						<#form:input path="keywords" maxlength="500" class="form-control width-120" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('描述')}：</label>
					<div class="control-inline">
						<#form:input path="description" maxlength="500" class="form-control width-120" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否在导航中显示')}：</label>
					<div class="control-inline">
						<#form:input path="inMenu" maxlength="1" class="form-control width-120" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否在分类页中显示列表')}：</label>
					<div class="control-inline">
						<#form:input path="inList" maxlength="1" class="form-control width-120" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('展现模式')}：</label>
					<div class="control-inline">
						<#form:input path="showModes" maxlength="1" class="form-control width-120" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否需要审核')}：</label>
					<div class="control-inline">
						<#form:input path="isNeedAudit" maxlength="1" class="form-control width-120" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否允许评论')}：</label>
					<div class="control-inline">
						<#form:input path="isCanComment" maxlength="1" class="form-control width-120" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('自定义列表视图')}：</label>
					<div class="control-inline">
						<#form:input path="customListView" maxlength="255" class="form-control width-120" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('自定义内容视图')}：</label>
					<div class="control-inline">
						<#form:input path="customContentView" maxlength="255" class="form-control width-120" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('视图配置')}：</label>
					<div class="control-inline">
						<#form:input path="viewConfig" maxlength="1000" class="form-control width-120" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('状态')}：</label>
					<div class="control-inline width-120">
						<#form:select path="status" dictType="sys_search_status" blankOption="true" class="form-control" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('备注信息')}：</label>
					<div class="control-inline">
						<#form:input path="remarks" maxlength="500" class="form-control width-120" />
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text("名称")}', name:'categoryName', index:'a.category_name', width:250, align:"left", frozen:true, formatter: function(val, obj, row, act){
			return '( '+row.categoryCode+' ) '+'<a href="${ctx}/cms/category/form?categoryCode='+row.categoryCode+'" class="btnList" data-title="${text("编辑栏目表")}">'+(val||row.id)+'</a>';
		}},
		{header:'${text("模型")}', name:'moduleType', index:'a.module_type', width:100, align:"center"},
		{header:'${text("排序")}', name:'treeSort', index:'a.tree_sort', width:50, align:"center"},
		{header:'${text("导航栏目")}', name:'inMenu', index:'a.in_menu', width:80, fixed:true, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('sys_show_hide')}, val, '未知', true);
		}},
		{header:'${text("栏目列表")}', name:'inList', index:'a.in_list', width:80, fixed:true, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('sys_show_hide')}, val, '未知', true);
		}},
		{header:'${text("展现方式")}', name:'showModes', index:'a.show_modes', width:150, fixed:true, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('cms_show_modes')}, val, '未知', true);
		}},
		{header:'${text("操作")}', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('cms:category:edit')){ %>
				actions.push('<a href="${ctx}/cms/category/form?categoryCode='+row.categoryCode+'" class="btnList" title="${text("编辑栏目表")}"><i class="fa fa-pencil"></i></a>&nbsp;');
				if (row.status == Global.STATUS_NORMAL){
					actions.push('<a href="${ctx}/cms/category/disable?categoryCode='+row.categoryCode+'" class="btnList" title="${text("停用栏目表")}" data-confirm="${text("确认要停用该栏目表吗？")}"><i class="glyphicon glyphicon-ban-circle"></i></a>&nbsp;');
				}
				if (row.status == Global.STATUS_DISABLE){
					actions.push('<a href="${ctx}/cms/category/enable?categoryCode='+row.categoryCode+'" class="btnList" title="${text("启用栏目表")}" data-confirm="${text("确认要启用该栏目表吗？")}"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');
				}
				actions.push('<a href="${ctx}/cms/category/delete?categoryCode='+row.categoryCode+'" class="btnList" title="${text("删除栏目表")}" data-confirm="${text("确认要删除该栏目表及所有子栏目表吗？")}" data-deltreenode="'+row.id+'"><i class="fa fa-trash-o"></i></a>&nbsp;');
				actions.push('<a href="${ctx}/cms/category/form?parentCode='+row.id+'" class="btnList" title="${text("新增下级栏目表")}"><i class="fa fa-plus-square"></i></a>&nbsp;');
			<% } %>
			return actions.join('');
		}}
	],
	treeGrid: true,			// 启用树结构表格
	defaultExpandLevel: 0,	// 默认展开的层次
	expandNodeClearPostData: 'categoryName,siteCode,moduleType,image,href,target,keywords,description,inMenu,inList,showModes,isNeedAudit,isCanComment,customListView,customContentView,viewConfig,status,remarks,', // 展开节点清理请求参数数据（一般设置查询条件的字段属性，否则在查询后，不能展开子节点数据）	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>